<!DOCTYPE HTML>
<html>
<!--_meta 作为公共模版分离出去-->
{include file="common/_meta"}
<!--/meta 作为公共模版分离出去-->

<body>
<!--_header 作为公共模版分离出去-->
{include file="common/_header"}
<!--/_header 作为公共模版分离出去-->
<!--_menu 作为公共模版分离出去-->
{include file="common/_menu"}
<!--/_menu 作为公共模版分离出去-->
<section class="Hui-article-box">
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 栏目管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
            <div class="pd-20 text-c">
                <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
                    <!-- <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>  -->
                    <a class="btn btn-primary radius"  href="{:url('add')}"><i class="Hui-iconfont">&#xe600;</i> 添加栏目</a></span> 
                    <span class="r">共有数据：<strong>54</strong> 条</span> </div>
                <div class="mt-20">
                    <table class="table table-border table-bordered table-hover table-bg table-sort">
                        <thead>
                            <tr class="text-c">
                                <th width="25"><input type="checkbox" name="" value=""></th>
                                <th width="80">ID</th>
                                <th width="160">栏目名称</th>
                                <th width="120">模板</th>
                                <th width="80">是否启用</th>
                                <th width="80">排序</th>
                                <th >描述</th>
                                <th width="240">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $data as $value}
                            <tr class="text-c" id="tr_{$value.id}">
                                <td><input type="checkbox" name="" value="{$value.id}"></td>
                                <td>{empty name="value._child"}<a href="javascript:void(0);"  onclick="loadsuns(this,{$value.id})" data-stat="0"> <img src="/static/images/subtract.gif">&nbsp;{$value.id}</a>
                                    {else/}<a href="javascript:void(0);" onclick='loadsuns(this,{$value.id})' data-stat="1" > <img src="/static/images/add.gif">&nbsp;{$value.id}</a>
                                    {/empty}
                                </td>
                                <td>{$value.category_icon}|{$value.category_name}</td>
                                <td>{$value.template}</td>
                                <td>{$value.isshow}</td>
                                <td>{$value.sort}</td>                                
                                <td class="text-l">{$value.desc}</td>
                                <td class="f-14">
                                    <a title="编辑" href="{:url('edit','id='.$value.id)}" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
                                    <a title="删除" href="javascript:;" onclick="category_del(this,{$value.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                                </td>
                            </tr>
                                {notempty name="value._child"}
                                {foreach  $value._child  as $val}
                                <tr class="text-c level_{$value.id}" style="display:none" id="tr_{$val.id}" >
                                    <td><input type="checkbox" name="" value="{$val.id}"></td>
                                    <td>{empty name="val._child"} <a href="javascript:void(0);"  onclick="loadsuns(this,{$val.id})" data-stat="0" >&nbsp;&nbsp;&nbsp;&nbsp;<img src="/static/images/subtract.gif">&nbsp;{$val.id}</a> 
                                        {else/} <a href="javascript:void(0);"  onclick="loadsuns(this,{$val.id})"data-stat="1" >&nbsp;&nbsp; &nbsp;&nbsp;<img src="/static/images/add.gif">&nbsp;{$val.id}</a>
                                        {/empty}   
                                    </td>
                                    <td>{$val.category_icon}{$val.category_name}</td>
                                    <td>{$val.template}</td>
                                    <td>{$val.isshow}</td>
                                    <td>{$val.sort}</td>                                
                                    <td class="text-l">{$val.desc}</td>
                                    <td class="f-14"><a title="编辑" href="{:url('edit','id='.$val.id)}" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
                                        <a title="删除" href="javascript:;" onclick="category_del(this,{$val.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                                    </td>
                                </tr>
                                    {notempty name="val._child"}
                                    {foreach $val._child as $vo}
                                    <tr class="text-c level_{$val.id}  grandson_{$value.id}" style="display:none" id="tr_{$vo.id}" >
                                        <td><input type="checkbox" name="" value="{$vo.id}"></td>
                                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="/static/images/subtract.gif">&nbsp;{$vo.id}</td>
                                        <td>{$vo.category_icon}{$vo.category_name}</td>
                                        <td>{$vo.template}</td>
                                        <td>{$vo.isshow}</td>
                                        <td>{$vo.sort}</td>                                
                                        <td class="text-l">{$vo.desc}</td>
                                        <td class="f-14">
                                            <a title="编辑" href="{:url('edit','id='.$vo.id)}" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> 
                                            <a title="删除" href="javascript:;" onclick="category_del(this,{$vo.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                                        </td>
                                    </tr>
                                    {/foreach}
                                    {/notempty}                                
                                {/foreach}
                                {/notempty}
                            {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
    
    </section>

<!--_footer 作为公共模版分离出去-->
{include file="common/_footer" /}
<!--/_footer 作为公共模版分离出去-->


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

/*系统-栏目-删除*/
function category_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
        $.ajax({
            type:"POST",
            data:{id:id},
            dataType:"json",
            url:"{:url('category/del')}",
            success:function(data){
                if(data.status==1){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else{
                    layer.msg('删除失败!',{icon:5,time:1000});
                }
            }
        })
	});
}

function loadsuns(obj,id){
    var stat = $(obj).data('stat');
    if(stat == 1){
        $(".level_"+id).css("display",'');
        $(obj).data('stat','0');
        $(obj).children('img').attr('src','/static/images/subtract.gif');
    }
    if(stat == 0){
        $(".level_"+id).css("display",'none');
        //有bug暂没解决
        // $(".level_"+id).children("td")['1'].children("a").children("img").attr('src','/static/images/add.gif');
        $(".grandson_"+id).css("display",'none');
        $(obj).data('stat','1');
        $(obj).children('img').attr('src','/static/images/add.gif');
    }
}


</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>